package com.mydemo.springlearning.functions.SpringAPI.collections;

import java.util.Arrays;
import java.util.List;

/**
 * @author hd
 * @date 2022-08-04 10:35
 * @description
 */
public class Array2List {
    public static void main(String[] args) {
        String[] strings = {"aaa", "bbb", "ccc"};
        System.out.println(array2List(strings));
        List<String> stringList = Arrays.asList(strings);
        System.out.println(Arrays.toString(list2Array(stringList)));
    }

    /**
     * 数组Array 2 集合List
     * @param strings
     * @return
     */
    public static List<String> array2List(String[] strings){
        List<String> strings1 = Arrays.asList(strings);
        return strings1;
    }

    /**
     * 集合List 2 数组Array
     *
     * @param stringList
     * @return
     */
    public static String[] list2Array(List<String> stringList){
        String[] strings = stringList.toArray(new String[0]);
        return strings;
    }
}
